﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class TestSceneMenu : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        //UnityEditor.SceneView.duringSceneGui
    }

    [InitializeOnLoadMethod]
    static void InitializeOnLoad() {
        UnityEditor.SceneView.duringSceneGui += (sceneView) =>
        {
            if ( Event.current != null && Event.current.button == 1 && Event.current.type == EventType.MouseUp ) {
                //Debug.Log(" 鼠标右键抬起! ");

                Rect position = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y-100, 100, 100);
                GUIContent[] contents = new GUIContent[] { new GUIContent("Test1"), new GUIContent("XFKT/Test2") };


                EditorUtility.DisplayCustomMenu(position, contents, -1, (data,opt,select) => {
                    Debug.LogFormat("data:{0},opt:{1},select:{2},value:{3}", data, opt, select, opt[select]);
                }, null);

                Event.current.Use();
            }
        };
    }
     
}
